package leetcode;

/**
 * Created by Ghost on 2014/12/28 0028.
 */
public class Excel_Sheet_Column_Number {
    public int titleToNumber(String s) {
        char[] ss = s.toCharArray();
        int n = ss.length-1;
        int sum = 0;
        for(int i=0;n>=0;n--,i++){
            sum=(26*sum+(ss[i]-'A'+1));
        }
        return sum;
    }
    public static void main(String[] args){
        Excel_Sheet_Column_Number excel_sheet_column_number = new Excel_Sheet_Column_Number();
        System.out.println(excel_sheet_column_number.titleToNumber("B"));
    }
}
